<?php
	include_once("DataProvider.php");
	include_once("../DTO/ctddhDTO.php");
	
	class ctddhDAO
	{
		public $sql = "";
		var $ctddhDTO;
		function __construct()
		{
			return $this->ctddhDTO = new ctddhDTO();
		}
		
		public function load()
		{
			$result= DataProvider::ExecuteQuery($this->sql);
			$arrctddhDTO = new ArrayObject();
			
			while($row = mysql_fetch_array($result))
			{
				$ctddhDTO = new ctddhDTO();
				$ctddhDTO->idCTHD = $row['idCTHD'];
				$ctddhDTO->idSP = $row['idSP'];
				$ctddhDTO->idDonDatHang = $row['idDonDatHang'];
				$ctddhDTO->giaBan = $row['giaBan'];
				$ctddhDTO->soLuong = $row['soLuong'];
				$ctddhDTO->giaSell1SP = $row['giaSell1SP'];
				
				$arrctddhDTO[] = $ctddhDTO;
			}
			return $arrctddhDTO;
		}
		
		public function load_All()
		{
			$this->sql= 'select * from ctddh';
			$result=$this->load();
			return $result; 
		}
		
		public function load_One($idCTHD)
		{
			$this->sql = 'select * from ctddh where idCTHD ='.$idCTHD;
			$result = $this->load();
			return $result;
		}
		
	}
	
?>